<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>考试管理</title>
<link rel="stylesheet" href="../static/layui/css/layui.css">
<style>    
  .layui-body{ padding: 10px;}
  .fen{margin:5px auto}
  .fenye{font-size:26px;}
</style>
</head>
<body>
	<br>
	<h2>考试管理</h2><br>

	<!-- 按钮区 -->
	<div class="site-demo-button" id="layerDemo" style="margin-bottom: 0;">
	  <button class="layui-btn">创建考试</button>
	  <button class="layui-btn">考试管理</button>
	</div></br>

	<!-- 主体内容区 -->
	<hr/>
   <table class="layui-table">
	  <colgroup>
	    <col width="100">
	  </colgroup>
	 <thead>
	     <tr>
	        <th><input type="checkbox"/></th>
	        <th>考试</th><th>考试时间</th><th>试卷总分</th><th>考试人次</th><th>及格分</th><th>操作</th>
	     </tr>
     </thead>
     <tbody>
     <c:forEach items="${examRecordlist}" var="rec">
       <tr>
       <td><input type='checkbox' name='st' /></td>
       <td>${rec.record_name}<br><a href="">${rec.exam_name}</a></td><td>${rec.record_start}<br>${rec.record_end}</td><td>${rec.exam_score}</td><td>
       <a href="exam_record?m=find&id=${rec.record_id }&count=${rec.count}&zongfen=${rec.exam_score}">${rec.count}</a></td><td>${rec.record_score}</td>
       <td>
    	<button type="button" class="layui-btn layui-btn-danger btndel1" dataid='${rec.record_id}'>删除</button>
    	<button type="button" class="layui-btn layui-btn-danger btndel2" dataid='${rec.record_id}'>添加考试学生</button>
       </td>
       </tr>
     </c:forEach>
     </tbody>
   </table>
   <!-- 分页 -->
   <div class="fen">
      <c:forEach begin="${pb.beginNum }" end="${pb.endNum }" varStatus="k">
	      <c:if test="${k.index == pb.curPage }">
	         <a class="fenye" style='background:red' href='exam_record?m=page&p=${k.index}'>${k.index}</a>
	      </c:if>
	      <c:if test="${k.index != pb.curPage}">
	         <a class="fenye" href='exam_record?m=page&p=${k.index}'>${k.index}</a>
	      </c:if>
      </c:forEach> 
   </div>
   
   <!-- 添加考试班级 -->
   <c:forEach items="${examRecordlist}" var="rec">
   <div class="layui-row" id="${rec.record_id}" style="display:none;">
 		<table class="layui-table">
 			<colgroup>
	    		<col width="100">
	  		</colgroup>
	  		
 			<c:forEach items="${classlist}" var="cls">
 				<tr><td><a href="exam_record?m=addClass&classid=${cls.class_id}&recordid=${rec.record_id}">${cls.class_name}</a></td></tr>
 			</c:forEach>
 		</table>
   </div>
   </c:forEach>
</body>
<script type="text/javascript" src="../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../static/layui/layui.js"></script>
<script type="text/javascript">
layui.use('layer', function(){ //独立版的layer无需执行这一句
	  var $ = layui.jquery, layer = layui.layer;
	  			 
	//所有删除BTN  加事件
	$(".btndel1").click(function(){
		var id = $(this).attr("dataid");
		layer.confirm('您确定要删除该考试吗?',{btn: ['确定', '取消'],title:"提示"},function(index){
            console.log("del ok " + id);  
            location.href="http://localhost:8080/OnlineExam1/admin/exam_record?m=del&id="+id;
            layer.close(index);
		});
	});

	//添加考试班级
	$(".btndel2").click(function(){
		var id = $(this).attr("dataid");
		var divobj = document.getElementById(id+"");
		layer.open({
			  title: '选择考试班级',
			  btn: ['关闭'],
			  area: '700px;',
			  content: $(divobj).html()
		});
	});
});
//按钮切换
$(function(){
    $("button:eq(0)").click(function(){
    	window.location.href='http://localhost:8080/OnlineExam1/admin/exam_record?m=addExam'
    });

    $("button:eq(1)").click(function(){
    	window.location.href='http://localhost:8080/OnlineExam1/admin/exam_record?m=page'
    }); 
});
</script>
</html>